<?php
	require '../../feed/config/config.php';
	session_start();
	$ConnfigRs=mysqli_fetch_array(mysqli_query($con,"select * from config where id='1'"));
	if(empty($_SESSION['member'])){
	    echo "<script>location='../index.php';</script>";
	}
	if($_GET['ops']=="logout"){
	    session_destroy();
	    session_start();
	    $_SESSION['url']="https://edu.yudur.cn/index/index.php";
	    echo "<script>alert('您已成功退出');location='../index.php';</script>";
	}
	if($_POST['submit']){
	    if(!empty($_POST['name']) && !empty($_POST['more'])){
	        $clubRs=mysqli_fetch_array(mysqli_query($con,"select * from club where name='".$_POST['name']."'"));
	        if($clubRs['name']==""){
	            $addClubRs=mysqli_query($con,"INSERT INTO `club` (`id`,`name`,`regTime`,`more`,`addUser`,`addKey`,`state`) VALUES ('','".$_POST['name']."','".date("Y/m/d H:i:s")."','".$_POST['more']."','".$_SESSION['member']."','".time().getRandomString(10)."','0')");
	            if($addClubRs){
	                $clubRs=mysqli_fetch_array(mysqli_query($con,"select * from club where name='".$_POST['name']."'")); 
	                mysqli_query($con,"INSERT INTO `clubIdentity` (`id`,`identityName`,`clubId`,`addTime`,`addUser`,`state`) VALUES ('','创建者','".$clubRs['id']."','".date("Y/m/d H:i:s")."','".$_SESSION['member']."','1')");
	                mysqli_query($con,"INSERT INTO `clubIdentity` (`id`,`identityName`,`clubId`,`addTime`,`addUser`,`state`) VALUES ('','未审核新用户','".$clubRs['id']."','".date("Y/m/d H:i:s")."','".$_SESSION['member']."','1')");
	                mysqli_query($con,"INSERT INTO `clubIdentity` (`id`,`identityName`,`clubId`,`addTime`,`addUser`,`state`) VALUES ('','干事','".$clubRs['id']."','".date("Y/m/d H:i:s")."','".$_SESSION['member']."','1')");
	                $clubIdentityRs=mysqli_fetch_array(mysqli_query($con,"select * from clubIdentity where identityName='创建者' and clubId='".$clubRs['id']."'")); 
	                mysqli_query($con,"INSERT INTO `clubUser` (`id`,`user`,`clubId`,`addTime`,`identityId`,`state`) VALUES ('','".$_SESSION['member']."','".$clubRs['id']."','".date("Y/m/d H:i:s")."','".$clubIdentityRs['id']."','1')");
	                echo "<script>alert('您已成功创建社团，请您新等待管理员审核！');location='./index.php';</script>";
	            }else{
	                echo "<script>alert('系统异常，创建社团失败！');history.back();</script>";
	            }
	        }else{
	            echo "<script>alert('系统已存在相同名称的社团，请检查后重试！');history.back();</script>";
	        }
	    }else{
	        echo "<script>alert('请填写完整信息！');history.back();</script>";
	    }
	}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8"/>
    <title>社团中心 - 新建社团</title>
    <script type="text/javascript" src="../js/base-loading.min.js"></script>
    <script type="text/javascript" src="../js/layui.js"></script>
    <link rel="stylesheet" href="../css/style.css"/>
    <link rel="stylesheet" href="../css/layui.css"/>
    <style>
    .cen_one{
        height: 500px;
    }
    .cen_one_fl{
        height: 480px;
    }
    .mF_liuzg{
        height: 400px;
        width: 500px;
        text-align: left;
        margin-left: -140px;
    }
    </style>
  </head>
  <body>
    <div class="s_header w">
      <div class="s_header_top w">
        <div class="header_top w1000 auto">
          <div class="header_top_fl fl">欢迎访问<?php echo $ConnfigRs['name'];?></div>
          <div class="header_top_fr fr"><span class="header_email dib"></span><span class="header_tel dib"></span>
            <div class="cb"></div>
          </div>
          <div class="cb"></div>
        </div>
      </div>
      <div class="s_header_nav w">
        <div class="header_nav w1000 auto">
          <div class="logo fl"><a href="index.html"><img src="http://www.huayu.edu.cn/template/huayu/listimages/logo.png" alt=""/></a></div>
        </div>
      </div>
    </div>
    <div class="banner">
      <div id="banner" class="dv_5"><a href="" style=" background:url(../images/hy.png) center center no-repeat; display: block; z-index: 1; " class="d1"></a><a href="" style=" background:url(images/banner2.png) center center no-repeat; display: block; z-index: 1; " class="d1"></a><a href="" style=" background:url(images/banner3.png) center center no-repeat; display: block; z-index: 1; " class="d1"></a>
      </div>
    </div>
    <div class="s_cen w">
      <div class="center w1000 auto">
          <br />
                <p><a href="../index.php">首页</a> / <a href="./index.php">社团中心</a> / 新建社团</p>
              <br />
        <div class="cen_one">
          <div class="cen_one_fl fl">
            <div class="jqal_top">
              <div class="jqal_top_tit fl">新建社团</div>
              <div class="cb"></div>
            </div>
            <div class="jqal_bom mychgPic">
              <div id="myFocus" class="mF_liuzg">
                <form method="post" action="./addclub.php">
                    <input type="text" name="name" placeholder="请输入社团名称" class="layui-input">
                    <br />
                    <textarea name="more" placeholder="请输入社团介绍" rows="15" cols="66"></textarea>
                    <br />
                    <input type="submit" name="submit" class='layui-btn layui-btn-normal' value="新建社团">
                </form>
              </div>
            </div>
          </div>
          <div class="cb"></div>
        </div>
      </div>
    </div>
    <div class="s_footer w">
      <div class="footer w1000 auto">
        <div class="footer_fl fl">
          <div class="footer_logo"><a href=""><img src="http://www.huayu.edu.cn/template/huayu/images/logo.png"  alt="" width="100%"/></a></div>
          <div class="footer_line"></div>
          <div class="footer_fl_ul">
            
          </div>
          <div class="cb"></div>
          <div class="footer_fl_record"></div>
        </div>
        <div class="footer_fr fr">
          <div class="footer_fr_top"></div>
          <div class="footer_line"></div>
         
          <div class="footer_from">｜<a href="" target="_blank">XXX</a></div>
        </div>
      </div>
    </div>
    <script type="text/javascript" src="../js/jquery-1.8.1.min.js"></script>
    <!--首页banner特效-->
    <script type="text/javascript" src="../js/banner.js"></script>
    <script type="text/javascript" src="../js/main.js"> </script>
    <script type="text/javascript" src="../js/jquery.SuperSlide.2.1.1.js"></script>
</body>
</html>